@using Akso.MultiTenancy
<div>
    <form name="tenantCreateForm" role="form" novalidate class="form-validation">
        <div class="modal-header">
            <h4 class="modal-title">
                <span>@L("CreateNewTenant")</span>
            </h4>
        </div>
        <div class="modal-body">
            
            <div class="form-group form-md-line-input form-md-floating-label no-hint">
                <input auto-focus class="form-control input-ltr" type="text" name="TenancyName" ng-model="vm.tenant.tenancyName" required maxlength="@Tenant.MaxTenancyNameLength" ng-pattern="/@Tenant.TenancyNameRegex/">
                <label>@L("TenancyName")</label>
            </div>
            <div>
                <span class="help-block text-danger" ng-show="!tenantCreateForm.TenancyName.$valid && tenantCreateForm.TenancyName.$dirty">@L("TenantName_Regex_Description")</span>
            </div>

            <div class="form-group form-md-line-input form-md-floating-label no-hint">
                <input type="text" name="Name" class="form-control" ng-model="vm.tenant.name" required maxlength="@Tenant.MaxNameLength">
                <label>@L("Name")</label>
            </div>

            <div class="md-checkbox-list">
                <div class="md-checkbox">
                    <input id="CreateTenant_UseHostDb" class="md-check" type="checkbox" name="UseHostDb" ng-model="vm.useHostDb">
                    <label for="CreateTenant_UseHostDb">
                        <span class="inc"></span>
                        <span class="check"></span>
                        <span class="box"></span>
                        @L("UseHostDatabase")
                    </label>
                </div>
            </div>

            <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-if="!vm.useHostDb">
                <input type="text" name="ConnectionString" class="form-control" ng-model="vm.tenant.connectionString" required maxlength="@Tenant.MaxConnectionStringLength">
                <label>@L("DatabaseConnectionString")</label>
            </div>

            <div class="form-group form-md-line-input form-md-floating-label no-hint">
                <input type="email" name="AdminEmailAddress" class="form-control" ng-model="vm.tenant.adminEmailAddress" required maxlength="@Akso.Authorization.Users.User.MaxEmailAddressLength">
                <label>@L("AdminEmailAddress")</label>
            </div>

            <div class="md-checkbox-list">
                <div class="md-checkbox">
                    <input id="CreateTenant_SetRandomPassword" class="md-check" type="checkbox" name="SetRandomPassword" ng-model="vm.setRandomPassword">
                    <label for="CreateTenant_SetRandomPassword">
                        <span class="inc"></span>
                        <span class="check"></span>
                        <span class="box"></span>
                        @L("SetRandomPassword")
                    </label>
                </div>
            </div>

            <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-if="!vm.setRandomPassword">
                <input type="password" name="Password" class="form-control" ng-model="vm.tenant.adminPassword" ng-required="!vm.setRandomPassword" maxlength="@Akso.Authorization.Users.User.MaxPlainPasswordLength">
                <label>@L("AdminPassword")</label>
            </div>

            <div class="form-group form-md-line-input form-md-floating-label no-hint" ng-if="!vm.setRandomPassword">
                <input type="password" name="AdminPasswordRepeat" class="form-control" ng-model="vm.tenant.adminPasswordRepeat" ng-required="!vm.setRandomPassword" maxlength="@Akso.Authorization.Users.User.MaxPlainPasswordLength" ui-validate=" '$value==vm.tenant.adminPassword' " ui-validate-watch=" 'vm.tenant.adminPassword' ">
                <label>@L("AdminPasswordRepeat")</label>
            </div>

            <div class="form-group form-md-line-input form-md-floating-label no-hint">
                <select id="TenantEditionSelectionCombobox" class="form-control edited" ng-options="vm.getEditionValue(item) as item.displayText for item in vm.editions" ng-model="vm.tenant.editionId"></select>
                <label for="TenantEditionSelectionCombobox">@L("Edition")</label>
            </div>

            <div class="md-checkbox-list">
                <div class="md-checkbox">
                    <input id="CreateTenant_ShouldChangePasswordOnNextLogin" class="md-check" type="checkbox" name="ShouldChangePasswordOnNextLogin" ng-model="vm.tenant.shouldChangePasswordOnNextLogin">
                    <label for="CreateTenant_ShouldChangePasswordOnNextLogin">
                        <span class="inc"></span>
                        <span class="check"></span>
                        <span class="box"></span>
                        @L("ShouldChangePasswordOnNextLogin")
                    </label>
                </div>
                <div class="md-checkbox">
                    <input id="CreateTenant_SendActivationEmail" class="md-check" type="checkbox" name="SendActivationEmail" ng-model="vm.tenant.sendActivationEmail">
                    <label for="CreateTenant_SendActivationEmail">
                        <span class="inc"></span>
                        <span class="check"></span>
                        <span class="box"></span>
                        @L("SendActivationEmail")
                    </label>
                </div>
                <div class="md-checkbox">
                    <input id="CreateTenant_IsActive" class="md-check" type="checkbox" name="IsActive" ng-model="vm.tenant.isActive">
                    <label for="CreateTenant_IsActive">
                        <span class="inc"></span>
                        <span class="check"></span>
                        <span class="box"></span>
                        @L("Active")
                    </label>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" ng-disabled="vm.saving" class="btn btn-default" ng-click="vm.cancel()">@L("Cancel")</button>
            <button type="submit" button-busy="vm.saving" busy-text="@L("SavingWithThreeDot")" class="btn btn-primary blue" ng-click="vm.save()" ng-disabled="tenantCreateForm.$invalid"><i class="fa fa-save"></i> <span>@L("Save")</span></button>
        </div>
    </form>
</div>
